/*
	ColorPicker is difficult to hack into, because many of its sub components have been declared as private,
	makeing their behaviors impossible to be overridden.
	You will notice that our skin cannot overlap the swatch preview, we may be able to fix that in future versions
*/ 
package org.delphy.indy2.controls
{
	import flash.events.Event;
	
	import mx.controls.ColorPicker;
	
	import org.delphy.indy2.core.ICarbonComponent;
	
	public class CarbonColorPicker extends ColorPicker implements ICarbonComponent
	{
		/**
		 * Constructor
		 */		
		public function CarbonColorPicker()
		{
			super();
			
			addEventListener(Event.CHANGE,onColorChange);
		}
		
		/**
		 * @protected
		 */
		 override protected function commitProperties():void{
		 	super.commitProperties();
		 	
		 	if(!styleName)
		 		styleName="carbonColorPicker";
		 		
		 	setStyle("skinColor", selectedColor);
		 }
		 
		/**
		 * @protected
		 */
		protected function onColorChange(evt:Event):void{
			setStyle("skinColor",selectedColor);
		}
		
		/**
		 * @public
		 */
		 public function get defaultStyleName():String{
		 	return "carbonColorPicker";
		 }
	}
}